<div class="monitor-tab-div">
    <!-- 基本信息 -->
    <div class="m-panel">
        <div class="m-panel-title">
            <span>基本信息</span>
        </div>
        <div class="m-panel-body base-info-div">
            <form class="bs-example form-horizontal xs-form">
                <div id="base_info_monitor_div">
                    <div class="form-group">
                        <label class="col-lg-2 control-label">监控器名称：</label>
                        <label class="col-lg-4 control-label tl" data-id="monitorName"></label>
                        <label class="col-lg-2 control-label">监控器类型：</label>
                        <label class="col-lg-4 control-label tl" data-id="monitorType"></label>
                    </div>
                </div>

                <div id="base_info_asset_div">
                    <div class="form-group" style="height:0;padding:0"></div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">被监控资产名称：</label>
                        <label class="col-lg-4 control-label tl" data-id="assetName"></label>
                        <label class="col-lg-2 control-label">资产类型：</label>
                        <label class="col-lg-4 control-label tl" data-id="assetTypeName"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">IP：</label>
                        <label class="col-lg-4 control-label tl" data-id="mainIp"></label>
                        <label class="col-lg-2 control-label">管控域：</label>
                        <label class="col-lg-4 control-label tl" data-id="securityDomainName"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">操作系统：</label>
                        <label class="col-lg-4 control-label tl" data-id="osTypeName"></label>
                        <label class="col-lg-2 control-label" style="display: none;">物理位置：</label>
                        <label class="col-lg-4 control-label tl" data-id="locationCbName" style="display: none;"></label>
                    </div>
                </div>
                
                <div id="base_info_asset_div2">
                    <div class="form-group">
                        <label class="col-lg-2 control-label">数据库版本：</label>
                        <label class="col-lg-4 control-label tl" data-id="version"></label>
                        <label class="col-lg-2 control-label"></label>
                        <label class="col-lg-4 control-label"></label>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <!-- 数据库信息 -->
    <div class="m-panel">
        <div class="m-panel-title">
            <span>数据库信息</span>
        </div>
        <div class="m-panel-body" id="database_div">
            <div class="m-panel-body-card">
                <ul>
                    <li class="active" data-action="database_list">数据库信息</li>
                </ul>
            </div>
            <div class="table-div" id="database_table" style="height:300px"></div>
        </div>
    </div>

    <!-- 数据库配置信息 -->
    <div class="m-panel">
        <div class="m-panel-title">
            <span>数据库配置信息</span>
        </div>
        <div class="m-panel-body base-info-div" id="database_config_div">
            <div class="m-panel-body-card">
                <ul>
                    <li class="active" data-action="count_info">计数器信息</li>
                    <li data-action="database_config_list">数据库配置信息</li>
                </ul>
            </div>
            <div id="count_info_div">
                <form class="bs-example form-horizontal xs-form">
                    <!-- 计数器信息 -->
                    <!-- <div id="count_info_div"> -->
                        <div class="form-group">
                            <label class="col-lg-2 control-label">会话数：</label>
                            <label class="col-lg-4 control-label tl" data-id="sessionCount"></label>
                            <label class="col-lg-2 control-label">活动事务数：</label>
                            <label class="col-lg-4 control-label tl" data-id="activeTransactions"></label>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">每秒事务数：</label>
                            <label class="col-lg-4 control-label tl" data-id="transcationPerSec"></label>
                            <label class="col-lg-2 control-label">锁数：</label>
                            <label class="col-lg-4 control-label tl" data-id="lockCount"></label>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">数据库数：</label>
                            <label class="col-lg-4 control-label tl" data-id="databaseCount"></label>
                            <label class="col-lg-2 control-label">事务总数：</label>
                            <label class="col-lg-4 control-label tl" data-id="totalTranscations"></label>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">死锁数量：</label>
                            <label class="col-lg-4 control-label tl" data-id="deadLockCount"></label>
                            <label class="col-lg-2 control-label"></label>
                            <label class="col-lg-4 control-label"></label>
                        </div>
                    <!-- </div>  -->
                </form>
            </div>
            
            <div class="table-div" id="database_config_table" style="height:300px;display: none;"></div>
        </div>
    </div>

    <div class="box">
        <div class="box-item" style="width:50%">
            <!-- 注册与注销数 -->
            <div class="m-panel">
                <div class="m-panel-title">
                    <span>注册与注销数</span>
                </div>
                <div class="m-panel-body">
                    <div id="regist_chart" class="monitor-chart" style="height:210px"></div>
                </div>
            </div>
        </div>
        <div class="box-item" style="width:50%">
            <!-- 高速缓存信息 -->
            <div class="m-panel">
                <div class="m-panel-title">
                    <span>高速缓存信息</span>
                </div>
                <div class="m-panel-body">
                    <div id="high_catch_chart" class="monitor-chart" style="height:210px"></div>
                </div>
            </div>
        </div>
    </div>

    <!-- 缓冲区、内存信息 -->
    <div class="m-panel">
        <div class="m-panel-title">
            <span>缓冲区/内存信息</span>
        </div>
        <div class="m-panel-body base-info-div" id="memeory_info_div">
            <div class="m-panel-body-card">
                <ul>
                    <li class="active" data-action="catch_info">缓冲区信息</li>
                    <li data-action="memory_info">内存信息</li>
                </ul>
            </div>
             <!-- 缓冲区信息 -->
            <div id="catch_info_div">
                <form class="bs-example form-horizontal xs-form">
                    <div class="form-group">
                        <label class="col-lg-2 control-label">sql server高速缓存页数：</label>
                        <label class="col-lg-4 control-label tl" data-id="cacheSize"></label>
                        <label class="col-lg-2 control-label">扩展内存高速缓存命中率（页面/秒）：</label>
                        <label class="col-lg-4 control-label tl" data-id="radio"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">空闲缓冲区数量：</label>
                        <label class="col-lg-4 control-label tl" data-id="freeBuffer"></label>
                        <label class="col-lg-2 control-label">每秒执行物理读取页数：</label>
                        <label class="col-lg-4 control-label tl" data-id="pagesRead"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">每秒执行物理写入页数：</label>
                        <label class="col-lg-4 control-label tl" data-id="pageWrite"></label>
                        <label class="col-lg-2 control-label">每秒预读物理页数：</label>
                        <label class="col-lg-4 control-label tl" data-id="readaheadPage"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">高速缓存保留页数：</label>
                        <label class="col-lg-4 control-label tl" data-id="reservedPage"></label>
                        <label class="col-lg-2 control-label">数据库页数：</label>
                        <label class="col-lg-4 control-label tl" data-id="databasePages"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">每秒映射数据库页的次数：</label>
                        <label class="col-lg-4 control-label tl" data-id="aweLookupMapsPerSec"></label>
                        <label class="col-lg-2 control-label">每秒映射缓冲区的次数：</label>
                        <label class="col-lg-4 control-label tl" data-id="aweStolenMapsPerSec"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">每秒必须映射到脏缓冲区的次数：</label>
                        <label class="col-lg-4 control-label tl" data-id="aweWriteMapsPerSec"></label>
                        <label class="col-lg-2 control-label">页在缓冲池中停留的秒数：</label>
                        <label class="col-lg-4 control-label tl" data-id="pageLifeExpectancy"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">每秒要求在缓冲池中查找页的请求数：</label>
                        <label class="col-lg-4 control-label tl" data-id="pageLookupsPerSec"></label>
                        <label class="col-lg-2 control-label">每秒为预期使用读取的页数：</label>
                        <label class="col-lg-4 control-label tl" data-id="readaheadPagesPerSec"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">获取时间：</label>
                        <label class="col-lg-4 control-label tl" data-id="updateDateBf"></label>
                        <label class="col-lg-2 control-label"></label>
                        <label class="col-lg-4 control-label"></label>
                    </div>
                </form>
            </div>
             <!-- 内存信息 -->
            <div id="memory_info_div" style="display: none;">
                <form class="bs-example form-horizontal xs-form">
                    <div class="form-group">
                        <label class="col-lg-2 control-label">维护连接内存量（KB）：</label>
                        <label class="col-lg-4 control-label tl" data-id="connectionMem"></label>
                        <label class="col-lg-2 control-label">授予排序、索引操作内存量（KB）：</label>
                        <label class="col-lg-4 control-label tl" data-id="grantWorMem"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">分配锁块总数量：</label>
                        <label class="col-lg-4 control-label tl" data-id="lockBlockAlloc"></label>
                        <label class="col-lg-2 control-label">分配锁内存量（KB）：</label>
                        <label class="col-lg-4 control-label tl" data-id="locksMemory"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">分配可执行进程内存总量：</label>
                        <label class="col-lg-4 control-label tl" data-id="maximumWorkMem"></label>
                        <label class="col-lg-2 control-label">获得工作空间内存授权进程数量：</label>
                        <label class="col-lg-4 control-label tl" data-id="memGrantOut"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">等待工作空间内存授权进程数量：</label>
                        <label class="col-lg-4 control-label tl" data-id="memGrantPend"></label>
                        <label class="col-lg-2 control-label">查询优化内存量（KB）：</label>
                        <label class="col-lg-4 control-label tl" data-id="optimizerMem"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">动态sql高速缓存总量（KB）：</label>
                        <label class="col-lg-4 control-label tl" data-id="sqlCacheMem"></label>
                        <label class="col-lg-2 control-label">服务器潜在消耗内存量：</label>
                        <label class="col-lg-4 control-label tl" data-id="targetServerMem"></label>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">服务器当前消耗内存总量：</label>
                        <label class="col-lg-4 control-label tl" data-id="totaServerMem"></label>
                        <label class="col-lg-2 control-label">获取时间：</label>
                        <label class="col-lg-4 control-label tl" data-id="updateDateM"></label>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- 作业明细、锁信息 -->
    <div class="m-panel">
        <div class="m-panel-title">
            <span>作业明细/锁信息</span>
        </div>
        <div class="m-panel-body base-info-div" id="lock_info_div">
            <div class="m-panel-body-card">
                <ul>
                    <li class="active" data-action="work_info_list">作业明细</li>
                    <li data-action="lock_info_list">锁信息</li>
                </ul>
            </div>
            <div class="table-div" id="lock_info_table" style="height:300px;"></div>
        </div>
    </div>
</div>

<div class="monitor-tab-div" data-type="event"></div>


<script type="text/javascript">
$(document).ready(function (){
require(['/js/plugin/monitor/catagory/sqlserver.js'] ,function (sqlserver){

var urlParamObj = index_query_param_get()

view_init()

function view_init()
{
    urlParamObj.time = $("#query_time_label").text()
    urlParamObj.edId = urlParamObj.assetId
    urlParamObj.instStatus = 1 
    urlParamObj.monitorTypeNameLanguage = 1 
    urlParamObj.dbName = $("#instance_sel").val()
    sqlserver.base_info_render(urlParamObj)
    sqlserver.dataBase_info_list($("#database_table"),urlParamObj)
    database_config_render()
    sqlserver.regist_chart($("#regist_chart"),urlParamObj)
    sqlserver.high_catch_chart($("#high_catch_chart"),urlParamObj)
    memeory_info_render()
    lock_info_render()
}


window.index_monitor_init = function ()
{
    view_init()
}

function base_info_render(){

}

function database_config_render(){
    var el_ul = $("#database_config_div").find("ul")
    el_ul.find("li").click(function (){
        $(this).siblings().removeClass("active")
        $(this).addClass("active")
        if ($(this).attr("data-action") == "count_info") {
            $("#database_config_div").find("#count_info_div").show()
            $("#database_config_div").find("#database_config_table").hide()
            sqlserver.count_info_render($("#count_info_div") ,urlParamObj)
        }
        else{
            $("#database_config_div").find("#count_info_div").hide()
            $("#database_config_div").find("#database_config_table").show()
            sqlserver.database_config_list($("#database_config_table") ,urlParamObj)
        }
        
    })
    sqlserver.count_info_render($("#count_info_div") ,urlParamObj)
}

function memeory_info_render(){
    var el_ul = $("#memeory_info_div").find("ul")
    el_ul.find("li").click(function (){
        $(this).siblings().removeClass("active")
        $(this).addClass("active")
        if ($(this).attr("data-action") == "catch_info") {
            $("#memeory_info_div").find("#catch_info_div").show()
            $("#memeory_info_div").find("#memory_info_div").hide()
            sqlserver.catch_info_render($("#catch_info_div") ,urlParamObj)
        }
        else{
            $("#memeory_info_div").find("#catch_info_div").hide()
            $("#memeory_info_div").find("#memory_info_div").show()
            sqlserver.memory_info_render($("#memory_info_div") ,urlParamObj)
        }
    })
    sqlserver.catch_info_render($("#catch_info_div") ,urlParamObj)
}

function lock_info_render(){
    var el_ul = $("#lock_info_div").find("ul")
    el_ul.find("li").click(function (){
        $(this).siblings().removeClass("active")
        $(this).addClass("active")
        sqlserver[$(this).attr("data-action")]($("#lock_info_table") ,urlParamObj)
    })
    sqlserver.work_info_list($("#lock_info_table") ,urlParamObj)
}

})
})
</script>